package org.lex.swing;

import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

public enum Option {
	YES("Yes"), NO("No"), CANCEL("Cancel");

	public static Option parseJOptionPaneReturns(int option) {
		if (option == JOptionPane.YES_OPTION || option == JOptionPane.OK_OPTION)
			return YES;
		else if (option == JOptionPane.NO_OPTION)
			return NO;
		else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION)
			return CANCEL;
		return CANCEL;
	}

	public static Option parseJFileChooserReturns(int option) {
		if (option == JFileChooser.APPROVE_OPTION)
			return YES;
		return CANCEL;
	}

	public boolean isYesOption() {
		return this == YES;
	}

	public boolean isNoOption() {
		return this == NO;
	}

	public boolean isCancelOption() {
		return this == CANCEL;
	}

	public String getDisplayName() {
		return this.displayName;
	}

	private String displayName = null;

	private Option(String displayName) {
		this.displayName = displayName;
	}
}
